package com.sam.expensetracker.dao;

import java.util.Date;
import java.util.Vector;

import net.rim.device.api.i18n.SimpleDateFormat;
import net.rim.device.api.util.Persistable;

public class ExpRec implements Persistable{

	public String day;
	public String category, desc;
	public int e1, e2, e3, e4;

	public ExpRec(Date day, String category, String desc, int e1, int e2,
			int e3, int e4) {
		super();
		SimpleDateFormat simpleDateFormat=new SimpleDateFormat("MMM dd yyyy");
		this.day = simpleDateFormat.format(day);
		this.category = category;
		this.desc = desc;
		this.e1 = e1;
		this.e2 = e2;
		this.e3 = e3;
		this.e4 = e4;
	}

	public ExpRec() {
		
	}
	
	public static int getDebt(Vector v) {
		if (v == null || v.size() == 0)
			return 0;
		int debt = 0, size = v.size();
		for (int i = 0; i < size; i++) {
			ExpRec expRec = (ExpRec) v.elementAt(i);
			debt = debt - expRec.e2 + expRec.e3;
		}
		return debt;
	}
	
	public int getNetDebt() {
		return e3-e2;
	}

}
